var cp = new cpaint();
cp.set_transfer_mode('get');
cp.set_response_type('xml');
cp.set_debug(0);

function uploaderror(msg)
{
	alert(msg);
}
function showfile()
{
    var countfld=1;
    countfld=document.getElementById("countfld").value+countfld;
    fld=countfld.length;
    if(fld>14)
    {
    alert("Sorry, i can upload  max 15 files at once.");    
    return false;
    }
    else
    {
        document.getElementById("f"+fld).style.display="block";
        document.getElementById("countfld").value=countfld;
    }
    
   var file=document.getElementById("f"+fld).value;
   if(file=="")
   {
        msg="Please fill this field.";
        alert(msg);        
        document.getElementById("f"+fld).focus();
        return false;
    }    
}
function showfileux()
{
    var countfld=1;
    countfld=document.getElementById("countfldu").value+countfld;
    fld=countfld.length;
    if(fld>14)
    {
    alert("Sorry, i can upload  max 15 files at once.");    
    return false;
    }
    else
    {
        document.getElementById("u"+fld).style.display="block";
        document.getElementById("countfldu").value=countfld;
    }    
}

function showfileu()
{
    var countfld=1;
    countfld=document.getElementById("countfldu").value+countfld;
    fld=countfld.length;
	fldx=fld-1;
	fldxx=fld.value;
	if(fldxx=="")
{
msg="Email Address cannot be left empty.";
alert(msg);
document.getElementById("u"+fldxx).select();
  document.getElementById("u"+fldxx).focus();
   return false;
}
    if(fld>14)
    {
    alert("Sorry, i can upload  max 15 files at once.");    
    return false;
    }
    else
    {
        document.getElementById("u"+fld).style.display="block";
        document.getElementById("countfldu").value=countfld;
    }    
}

function uploadfile(id)
{
    if(document.getElementById(id).value==1)
    {
    document.getElementById("showurl").style.display="none";
    document.getElementById("showfl").style.display="block";        
    return true;
    }
    if(document.getElementById(id).value==2)
    {
    document.getElementById("showfl").style.display="none";
    document.getElementById("showurl").style.display="block";    
    return true;
    }
    document.getElementById("countfldu").value="0";
    document.getElementById("countfld").value="0";
    

}

function show_loading()
{
        document.getElementById('loading').style.display = "block";
        document.getElementById('newupload').submit;
        document.getElementById('submit').disabled = true;
       // return true;
}
function show_loading1()
{
        document.getElementById('loading1').style.display = "block";
        document.getElementById('newupload1').submit;
        document.getElementById('submit').disabled = true;
}

function upload(msg,newID,messages,FileName,FileFile,FileUrl,FileUrlLink,FiletnUrl,page_url,server_url,site_name,HotLink)
{
var html='<div id = "add"></div><div id="wrapper"><div style="width:760px;"><center><FONT FACE="Comic Sans MS" SIZE="4" COLOR="#FF0000">&#1492;&#1506;&#1500;&#1488;&#1514;&#32;&#1514;&#1502;&#1493;&#1504;&#1492;</FONT></h4></center><form name="uploadresults" action="uploademail.php" method="post">';
if(newID)
{    
    html=html+'<input type="hidden" name="idx[]" value="'+newID+'">';
}

if(msg)
    {
        var getmsg = msg.split("|");
        for(i=0;i<getmsg.length;i++)
            {
                if(getmsg[i] && getmsg[i]!="on")
                html=html+'<span style="font-weight: bold; color: red;">'+getmsg[i]+'</span>';
            }
            
    }    
html=html+'<br><center>';    
if(messages)
    {
        
        var getmessages = messages.split("|");
        for(i=0;i<getmessages.length;i++)
            {
                if(getmessages[i] && getmessages[i]!="on")                
                html=html+'<span style="font-weight: bold; color: red;">'+getmessages[i]+'</span>';
            }
            html=html+'</center>';    
    }    


if(FileName)
    {
        var getFileName = FileName.split("|");
        var getFileFile = FileFile.split("|");
        var getFileUrl = FileUrl.split("|");
        var getFileUrlLink = FileUrlLink.split("|");
        var getFiletnUrl = FiletnUrl.split("|");
        var getHotLink = HotLink.split("|");
                for(i=0;i<getFileName.length;i++)
                        {
                                if(getFileName[i] && getFileName[i]!="on")        {
				html=html+'<table><tr><td><center><img src="'+getFiletnUrl[i]+'" alt="&#1500;&#1488;&#32;&#1504;&#1502;&#1510;&#1488;&#1492;&#32;&#1514;&#1502;&#1493;&#1504;&#1492;&#32;&#1502;&#1493;&#1511;&#1496;&#1504;&#1514;"/></center></td><td><strong>&#58;&#1514;&#1502;&#1493;&#1504;&#1492;&#32;&#1502;&#1493;&#1511;&#1496;&#1504;&#1514;</strong></td></tr>';

html=html+'<tr><td><textarea name="url1[]" cols="55" rows="1" READONLY onfocus="javascript: this.select()">'+server_url+'/view.php?filename='+getFileUrlLink[i]+'</textarea></td><td><strong>&#58;&#1511;&#1497;&#1513;&#1493;&#1512;&#32;&#1500;&#1510;&#1508;&#1497;&#1497;&#1492;&#32;&#1489;&#1514;&#1502;&#1493;&#1504;&#1492;</strong></td></tr>';

html=html+'<tr><td><textarea name="url4[]" cols="55" rows="2" READONLY onfocus="javascript: this.select()">[URL='+page_url+'][img]'+getFileUrl[i]+'[/img][/URL]</textarea></td><td><strong>&#58;&#1511;&#1493;&#1491;&#32;&#1500;&#1508;&#1497;&#1512;&#1505;&#1493;&#1501;&#32;&#1514;&#1502;&#1493;&#1504;&#1492;&#32;&#1489;&#1508;&#1493;&#1512;&#1493;&#1501;</strong></td></tr>';

html=html+'<tr><td><textarea name="url5[]" cols="55" rows="2" READONLY onfocus="javascript: this.select()">[URL='+page_url+'][img]'+getFiletnUrl[i]+'[/img][/URL]</textarea></td><td><strong>&#58;&#1511;&#1493;&#1491;&#32;&#1500;&#1508;&#1497;&#1512;&#1505;&#1493;&#1501;&#32;&#1514;&#1502;&#1493;&#1504;&#1492;&#32;&#1502;&#1493;&#1511;&#1496;&#1504;&#1514;&#32;&#1489;&#1508;&#1493;&#1512;&#1493;&#1501;</strong></td></tr>';

html=html+'<tr><td><textarea name="url6[]" cols="55" rows="2" READONLY onfocus="javascript: this.select()"><a href="'+server_url+'/" target="_blank"><img src="'+getFileUrl[i]+'" alt="&#1492;&#1506;&#1500;&#1488;&#1514;&#32;&#1514;&#1502;&#1493;&#1504;&#1493;&#1514;"></a></textarea></td><td><strong>&#58;&#1511;&#1493;&#1491;&#32;&#1500;&#1508;&#1497;&#1512;&#1505;&#1493;&#1501;&#32;&#1514;&#1502;&#1493;&#1504;&#1492;&#32;&#1489;&#1488;&#1514;&#1512;</strong></td></tr>';

html=html+'<tr><td><textarea name="url5[]" cols="55" rows="2" READONLY onfocus="javascript: this.select()"><a href="'+server_url+'/" target="_blank"><img src="'+getFiletnUrl[i]+'" alt="&#1492;&#1506;&#1500;&#1488;&#1514;&#32;&#1514;&#1502;&#1493;&#1504;&#1493;&#1514;"></a></textarea></td><td><strong>&#58;&#1511;&#1493;&#1491;&#32;&#1500;&#1508;&#1497;&#1512;&#1505;&#1493;&#1501;&#32;&#1514;&#1502;&#1493;&#1504;&#1492;&#32;&#1502;&#1493;&#1511;&#1496;&#1504;&#1514;&#32;&#1489;&#1488;&#1514;&#1512;</strong></td></tr></table><hr />';
                                }
								
                        }                
                        html=html+'<center>&#46;&#1489;&#1502;&#1511;&#1493;&#1501;&#32;&#1500;&#1512;&#1513;&#1493;&#1501;&#32;&#1488;&#1493;&#32;&#1500;&#1494;&#1499;&#1493;&#1512;&#32;&#1488;&#1514;&#32;&#1492;&#1511;&#1497;&#1513;&#1493;&#1512;&#1497;&#1501;&#44;&#32;&#1502;&#1500;&#1488;&#1493;&#32;&#1488;&#1514;&#32;&#1499;&#1514;&#1493;&#1489;&#1514;&#32;&#1492;&#1488;&#1497;&#1502;&#1497;&#1497;&#1500;&#32;&#1513;&#1500;&#1499;&#1501;&#32;&#1493;&#1514;&#1511;&#1489;&#1500;&#1493;&#32;&#1488;&#1514;&#32;&#1499;&#1500;&#32;&#1492;&#1508;&#1512;&#1496;&#1497;&#1501;&#32;&#1500;&#1488;&#1497;&#1502;&#1497;&#1497;&#1500;<br><div align="center"><input type="text" name="email" size="25" maxlength="50" /><strong>:&#1499;&#1514;&#1493;&#1489;&#1514;&#32;&#1492;&#1488;&#1497;&#1502;&#1497;&#1497;&#1500;</strong><br><input type="submit" name="submit" value="&#1513;&#1500;&#1495;&#32;&#1488;&#1514;&#32;&#1492;&#1511;&#1497;&#1513;&#1493;&#1512;&#1497;&#1501;" /></div></form></span></div></div><br/>';
        }  
    
    document.getElementById("showform").style.display="none";
    document.getElementById("showoutput").style.display="block";
    document.getElementById("showoutput").innerHTML=html;        
    return false;

}
